<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0044)http://www.beyondlogic.org/serial/serial.htm -->
<HTML>
<!-- Mirrored from bos.asmhackers.net/docs/serial/docs/serial.htm by HTTrack Website Copier/3.x [XR&CO'2013], Tue, 07 Oct 2014 11:24:12 GMT -->
<HEAD><TITLE>Interfacing The Serial / RS-232 Port</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1251">
<META 
content="Describes interfacing the Serial (RS-232) Port in relation to both Hardware and Software. Gives Practical Examples using CDP6402 UART and Software Examples in C." 
name=description>
<META 
content="RS232, RS-232, Serial, CPD6402, AY-5-1015, 8250, 16450, 16550, 16650, 16750, UART, MAX-232, COMMS, COM Port, Serial Port, Terminal, Programming in C, Serial Programming, RS-232 Programming" 
name=keywords>
<META content="MSHTML 5.50.4611.1300" name=GENERATOR></HEAD>
<BODY background=serial_files/background.gif> 
<STYLE type=text/css>#TITLEBLOCK {
	COLOR: #ffffff; TEXT-DECORATION: none
}
TD {
	FONT-FAMILY: Arial
}
P {
	FONT-FAMILY: Arial
}
FONT {
	FONT-FAMILY: Arial
}
A {
	FONT-FAMILY: Arial
}
</STYLE>

<CENTER><BR><BR><A href="http://www.beyondlogic.org/"><IMG 
alt="Interfacing the PC / Beyond Logic" src="serial_files/interface.gif" 
border=0></A> <BR>
<TABLE width="70%">
  <TBODY>
  <TR>
    <TD>
      <DIV align=right><FONT face=ARIAL size=+1>Quality Information in one Place 
      . . .</FONT></DIV></TD></TR></TBODY></TABLE><BR>
<TABLE width="90%" border=0>
  <TBODY>
  <TR>
    <TD width="20%" bgColor=blue height=25><FONT face=ARIAL color=white><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/index.html#PARALLEL">Parallel 
      Ports</A></CENTER></B></FONT></TD>
    <TD width="20%" bgColor=blue height=25><FONT face=ARIAL color=white><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/index.html#SERIAL">Serial 
      Ports</A></CENTER></B></FONT></TD>
    <TD width="20%" bgColor=blue height=25><FONT face=ARIAL color=white><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/index.html#INTERRUPTS">Interrupts</A></CENTER></B></FONT></TD>
    <TD width="20%" bgColor=blue height=25><FONT face=ARIAL color=white><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/index.html#ATKEYBOARDS">AT Keyboard 
      Ports</A></CENTER></B></FONT></TD>
    <TD width="20%" bgColor=blue height=25><FONT face=ARIAL color=white><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/index.html#USB">USB</A></CENTER></B></FONT></TD></TR></TBODY></TABLE><BR>
<HR>
<FONT face=IMPACT size=+3><B>Interfacing the Serial / RS232 
Port</B></FONT></CENTER>
<HR>

<UL><FONT face=ARIAL>
  <P>The Serial Port is harder to interface than the Parallel Port. In most 
  cases, any device you connect to the serial port will need the serial 
  transmission converted back to parallel so that it can be used. This can be 
  done using a UART. On the software side of things, there are many more 
  registers that you have to attend to than on a Standard Parallel Port. (SPP) 
  </P>
  <P>So what are the advantages of using serial data transfer rather than 
  parallel? </P>
  <TABLE>
    <TBODY>
    <TR>
      <TD vAlign=top>1.</TD>
      <TD>
        <P>Serial Cables can be longer than Parallel cables. The serial port 
        transmits a '1' as -3 to -25 volts and a '0' as +3 to +25 volts where as 
        a parallel port transmits a '0' as 0v and a '1' as 5v. Therefore the 
        serial port can have a maximum swing of 50V compared to the parallel 
        port which has a maximum swing of 5 Volts. Therefore cable loss is not 
        going to be as much of a problem for serial cables than they are for 
        parallel. </P></TD></TR>
    <TR>
      <TD vAlign=top>2.</TD>
      <TD>
        <P>You don't need as many wires than parallel transmission. If your 
        device needs to be mounted a far distance away from the computer then 3 
        core cable (Null Modem Configuration) is going to be a lot cheaper that 
        running 19 or 25 core cable. However you must take into account the cost 
        of the interfacing at each end. </P></TD></TR>
    <TR>
      <TD vAlign=top>3.</TD>
      <TD>
        <P>Infra Red devices have proven quite popular recently. You may of seen 
        many electronic diaries and palmtop computers which have infra red 
        capabilities build in. However could you imagine transmitting 8 bits of 
        data at the one time across the room and being able to (from the devices 
        point of view) decipher which bits are which? Therefore serial 
        transmission is used where one bit is sent at a time. IrDA-1 (The first 
        infra red specifications) was capable of 115.2k baud and was interfaced 
        into a UART. The pulse length however was cut down to 3/16th of a RS232 
        bit length to conserve power considering these devices are mainly used 
        on diaries, laptops and palmtops. </P></TD></TR>
    <TR>
      <TD vAlign=top>4.</TD>
      <TD>
        <P>Microcontroller's have also proven to be quite popular recently. Many 
        of these have in built SCI (Serial Communications Interfaces) which can 
        be used to talk to the outside world. Serial Communication reduces the 
        pin count of these MPU's. Only two pins are commonly used, Transmit Data 
        (TXD) and Receive Data (RXD) compared with at least 8 pins if you use a 
        8 bit Parallel method (You may also require a Strobe). 
  </P></TD></TR></TBODY></TABLE></UL><A name=TOC><A>
<P>
<HR>
<I><FONT size=+2>
<CENTER>Table of Contents</CENTER></FONT></I>
<HR>

<P></P>
<P>
<CENTER><FONT size=+1><B>Part 1 : Hardware (PC's)</B></FONT><BR><A 
href="http://www.beyondlogic.org/serial/serial.htm#1">Hardware 
Properties</A><BR><A 
href="http://www.beyondlogic.org/serial/serial.htm#2">Serial Pinouts (D25 and D9 
connectors)<BR><A href="http://www.beyondlogic.org/serial/serial.htm#3">Pin 
Functions </A><BR><A href="http://www.beyondlogic.org/serial/serial.htm#4">Null 
Modems </A><BR><A href="http://www.beyondlogic.org/serial/serial.htm#5">Loopback 
Plugs</A><BR><A href="http://www.beyondlogic.org/serial/serial.htm#6">DTE/DCE 
Speeds</A><BR><A href="http://www.beyondlogic.org/serial/serial.htm#7">Flow 
Control </A><BR><A href="http://www.beyondlogic.org/serial/serial.htm#8">The 
UART (8250's and Compatibles) </A><BR><A 
href="http://www.beyondlogic.org/serial/serial.htm#9">Type of UARTS (For PC's) 
</A><BR><FONT size=+1><B>Part 2 : Serial Ports' Registers 
(PC's)</B></FONT><BR><A 
href="http://www.beyondlogic.org/serial/serial.htm#12">Port Addresses and 
IRQ's</A><BR><A href="http://www.beyondlogic.org/serial/serial.htm#13">Table of 
Registers</A><BR><A href="http://www.beyondlogic.org/serial/serial.htm#14">DLAB 
? </A><BR><A href="http://www.beyondlogic.org/serial/serial.htm#15">Interrupt 
Enable Register (IER)</A><BR><A 
href="http://www.beyondlogic.org/serial/serial.htm#16">Interrupt Identification 
Register (IIR)</A><BR><A 
href="http://www.beyondlogic.org/serial/serial.htm#17">First In / First Out 
Control Register (FCR)</A><BR><A 
href="http://www.beyondlogic.org/serial/serial.htm#18">Line Control Register 
(LCR)</A><BR><A href="http://www.beyondlogic.org/serial/serial.htm#19">Modem 
Control Register (MCR)</A><BR><A 
href="http://www.beyondlogic.org/serial/serial.htm#20">Line Status Register 
(LSR)</A><BR><A href="http://www.beyondlogic.org/serial/serial.htm#21">Modem 
Status Register (MSR)</A><BR><A 
href="http://www.beyondlogic.org/serial/serial.htm#22">Scratch 
Register</A><BR><FONT size=+1><B>Part 3 : Programming (PC's)</B></FONT><BR><A 
href="http://www.beyondlogic.org/serial/serial1.htm#30">Polling or Interrupt 
Driven?</A><BR><A href="http://www.beyondlogic.org/serial/termpoll.c">Source 
Code - Termpoll.c (Polling Version)</A><BR><A 
href="http://www.beyondlogic.org/serial/buff1024.c">Source Code - Buff1024.c 
(ISR Version) </A><BR><A 
href="http://www.beyondlogic.org/serial/serial1.htm#31">Interrupt 
Vectors</A><BR><A 
href="http://www.beyondlogic.org/serial/serial1.htm#32">Interrupt Service 
Routine</A><BR><A href="http://www.beyondlogic.org/serial/serial1.htm#33">UART 
Configuration</A><BR><A 
href="http://www.beyondlogic.org/serial/serial1.htm#34">Main Routine 
(Loop)</A><BR><A 
href="http://www.beyondlogic.org/serial/serial1.htm#35">Determining the type of 
UART via Software</A><BR><FONT size=+1><B>Part 4 : External Hardware - 
Interfacing Methods</B></FONT><BR><A 
href="http://www.beyondlogic.org/serial/serial1.htm#40">RS-232 
Waveforms</A><BR><A 
href="http://www.beyondlogic.org/serial/serial1.htm#41">RS-232 Level 
Converters</A><BR><A 
href="http://www.beyondlogic.org/serial/serial1.htm#42">Making use of the Serial 
Format</A><BR><A href="http://www.beyondlogic.org/serial/serial1.htm#43">8250 
and compatable UART's</A><BR><A 
href="http://www.beyondlogic.org/serial/serial1.htm#44">CDP6402, AY-5-1015 / 
D36402R-9 etc UARTs</A><BR><A 
href="http://www.beyondlogic.org/serial/serial1.htm#46">Microcontrollers</A><BR>
<P></P></CENTER><A name=part1></A>
<HR width="100%">
<I><FONT size=+2>Part One : Hardware (PC's)</FONT></I>
<HR width="100%">

<P></P>
<UL>
  <P><A name=1><FONT size=+1>Hardware Properties</FONT>
  <HR>
  </A>
  <P></P>
  <P>Devices which use serial cables for their communication are split into two 
  categories. These are DCE (Data Communications Equipment) and DTE (Data 
  Terminal Equipment.) Data Communications Equipment are devices such as your 
  modem, TA adapter, plotter etc while Data Terminal Equipment is your Computer 
  or Terminal. </P>
  <P>The electrical specifications of the serial port is contained in the EIA 
  (Electronics Industry Association) RS232C standard. It states many parameters 
  such as - </P>
  <CENTER>
  <TABLE width="80%">
    <TBODY>
    <TR>
      <TD vAlign=top>1.</TD>
      <TD>A "Space" (logic 0) will be between +3 and +25 Volts. </TD></TR>
    <TR>
      <TD vAlign=top>2.</TD>
      <TD>A "Mark" (Logic 1) will be between -3 and -25 Volts. </TD></TR>
    <TR>
      <TD vAlign=top>3.</TD>
      <TD>The region between +3 and -3 volts is undefined. </TD></TR>
    <TR>
      <TD vAlign=top>4.</TD>
      <TD>An open circuit voltage should never exceed 25 volts. (In Reference 
        to GND) </TD></TR>
    <TR>
      <TD vAlign=top>5.</TD>
      <TD>A short circuit current should not exceed 500mA. The driver should 
        be able to handle this without damage. (Take note of this one!) 
    </TD></TR></TBODY></TABLE></CENTER>
  <P>Above is no where near a complete list of the EIA standard. Line 
  Capacitance, Maximum Baud Rates etc are also included. For more information 
  please consult the EIA RS232-C standard. It is interesting to note however, 
  that the RS232C standard specifies a maximum baud rate of 20,000 BPS!, which 
  is rather slow by today's standards. A new standard, RS-232D has been recently 
  released. </P>
  <P>Serial Ports come in two "sizes", There are the D-Type 25 pin connector and 
  the D-Type 9 pin connector both of which are male on the back of the PC, thus 
  you will require a female connector on your device. Below is a table of pin 
  connections for the 9 pin and 25 pin D-Type connectors. </P>
  <P><A name=2><FONT size=+1>Serial Pinouts (D25 and D9 Connectors)</FONT><BR>
  <HR>
  </A>
  <P></P>
  <P>
  <CENTER>
  <TABLE width="80%" border=1>
    <TBODY>
    <TR>
      <TD width="25%">
        <CENTER><B>D-Type-25 Pin No. </B></CENTER></TD>
      <TD width="25%">
        <CENTER><B>D-Type-9 Pin No. </B></CENTER></TD>
      <TD width="20%">
        <CENTER><B>Abbreviation</B></CENTER></TD>
      <TD width="30%">
        <CENTER><B>Full Name </B></CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 2 </CENTER></TD>
      <TD>
        <CENTER>Pin 3 </CENTER></TD>
      <TD>
        <CENTER>TD </CENTER></TD>
      <TD>
        <CENTER>Transmit Data </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 3 </CENTER></TD>
      <TD>
        <CENTER>Pin 2 </CENTER></TD>
      <TD>
        <CENTER>RD </CENTER></TD>
      <TD>
        <CENTER>Receive Data </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 4 </CENTER></TD>
      <TD>
        <CENTER>Pin 7 </CENTER></TD>
      <TD>
        <CENTER>RTS </CENTER></TD>
      <TD>
        <CENTER>Request To Send </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 5 </CENTER></TD>
      <TD>
        <CENTER>Pin 8 </CENTER></TD>
      <TD>
        <CENTER>CTS </CENTER></TD>
      <TD>
        <CENTER>Clear To Send </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 6 </CENTER></TD>
      <TD>
        <CENTER>Pin 6 </CENTER></TD>
      <TD>
        <CENTER>DSR </CENTER></TD>
      <TD>
        <CENTER>Data Set Ready </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 7 </CENTER></TD>
      <TD>
        <CENTER>Pin 5 </CENTER></TD>
      <TD>
        <CENTER>SG </CENTER></TD>
      <TD>
        <CENTER>Signal Ground </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 8 </CENTER></TD>
      <TD>
        <CENTER>Pin 1 </CENTER></TD>
      <TD>
        <CENTER>CD </CENTER></TD>
      <TD>
        <CENTER>Carrier Detect </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 20 </CENTER></TD>
      <TD>
        <CENTER>Pin 4 </CENTER></TD>
      <TD>
        <CENTER>DTR </CENTER></TD>
      <TD>
        <CENTER>Data Terminal Ready </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 22 </CENTER></TD>
      <TD>
        <CENTER>Pin 9 </CENTER></TD>
      <TD>
        <CENTER>RI </CENTER></TD>
      <TD>
        <CENTER>Ring Indicator </CENTER></TD></TR></TBODY></TABLE><FONT size=-1>
  <CENTER>Table 1 : D Type 9 Pin and D Type 25 Pin Connectors 
  </CENTER></FONT></CENTER>
  <P></P>
  <P><A name=3><FONT size=+1>Pin Functions</FONT><BR></A>
  <HR>

  <P></P>
  <P>
  <TABLE>
    <TBODY>
    <TR>
      <TD>&nbsp;</TD>
      <TD vAlign=top colSpan=2><B>Abbreviation</B></TD>
      <TD vAlign=top><B>Full Name</B></TD>
      <TD><B>Function</B></TD></TR>
    <TR>
      <TD>&nbsp;</TD>
      <TD>&nbsp;&nbsp;</TD>
      <TD vAlign=top>TD</TD>
      <TD vAlign=top>Transmit Data</TD>
      <TD>Serial Data Output (TXD)</TD></TR>
    <TR>
      <TD>&nbsp;</TD>
      <TD>&nbsp;&nbsp;</TD>
      <TD vAlign=top>RD</TD>
      <TD vAlign=top>Receive Data</TD>
      <TD>Serial Data Input (RXD)</TD></TR>
    <TR>
      <TD>&nbsp;</TD>
      <TD>&nbsp;&nbsp;</TD>
      <TD vAlign=top>CTS</TD>
      <TD vAlign=top>Clear to Send</TD>
      <TD>This line indicates that the Modem is ready to exchange data.</TD></TR>
    <TR>
      <TD>&nbsp;</TD>
      <TD>&nbsp;&nbsp;</TD>
      <TD vAlign=top>DCD</TD>
      <TD vAlign=top>Data Carrier Detect</TD>
      <TD>When the modem detects a "Carrier" from the modem at the other end 
        of the phone line, this Line becomes active.</TD></TR>
    <TR>
      <TD>&nbsp;</TD>
      <TD>&nbsp;&nbsp;</TD>
      <TD vAlign=top>DSR</TD>
      <TD vAlign=top>Data Set Ready</TD>
      <TD>This tells the UART that the modem is ready to establish a 
    link.</TD></TR>
    <TR>
      <TD>&nbsp;</TD>
      <TD>&nbsp;&nbsp;</TD>
      <TD vAlign=top>DTR</TD>
      <TD vAlign=top>Data Terminal Ready</TD>
      <TD>This is the opposite to DSR. This tells the Modem that the UART is 
        ready to link.</TD></TR>
    <TR>
      <TD>&nbsp;</TD>
      <TD>&nbsp;&nbsp;</TD>
      <TD vAlign=top>RTS</TD>
      <TD vAlign=top>Request To Send</TD>
      <TD>This line informs the Modem that the UART is ready to exchange 
      data.</TD></TR>
    <TR>
      <TD>&nbsp;</TD>
      <TD>&nbsp;&nbsp;</TD>
      <TD vAlign=top>RI</TD>
      <TD vAlign=top>Ring Indicator</TD>
      <TD>Goes active when modem detects a ringing signal from the 
    PSTN.</TD></TR></TBODY></TABLE></P>
  <P><A name=4><FONT size=+1>Null Modems</FONT>
  <HR>
  </A>
  <P></P>
  <P>A Null Modem is used to connect two DTE's together. This is commonly used 
  as a cheap way to network games or to transfer files between computers using 
  Zmodem Protocol, Xmodem Protocol etc. This can also be used with many 
  Microprocessor Development Systems.</P>
  <CENTER>
  <P><IMG height=148 alt="Null Modem Connections" 
  src="serial_files/nullmode.gif" width=391> <BR><FONT size=-1>Figure 1 : Null 
  Modem Wiring Diagram</FONT></P></CENTER>
  <CENTER></CENTER>
  <P>Above is my preferred method of wiring a Null Modem. It only requires 3 
  wires (TD, RD &amp; SG) to be wired straight through thus is more cost 
  effective to use with long cable runs. The theory of operation is reasonably 
  easy. The aim is to make to computer think it is talking to a modem rather 
  than another computer. Any data transmitted from the first computer must be 
  received by the second thus TD is connected to RD. The second computer must 
  have the same set-up thus RD is connected to TD. Signal Ground (SG) must also 
  be connected so both grounds are common to each computer.</P>
  <P>The Data Terminal Ready is looped back to Data Set Ready and Carrier Detect 
  on both computers. When the Data Terminal Ready is asserted active, then the 
  Data Set Ready and Carrier Detect immediately become active. At this point the 
  computer thinks the Virtual Modem to which it is connected is ready and has 
  detected the carrier of the other modem.</P>
  <P>All left to worry about now is the Request to Send and Clear To Send. As 
  both computers communicate together at the same speed, flow control is not 
  needed thus these two lines are also linked together on each computer. When 
  the computer wishes to send data, it asserts the Request to Send high and as 
  it's hooked together with the Clear to Send, It immediately gets a reply that 
  it is ok to send and does so.</P>
  <P>Notice that the ring indicator is not connected to anything of each end. 
  This line is only used to tell the computer that there is a ringing signal on 
  the phone line. As we don't have a modem connected to the phone line this is 
  left disconnected.</P><A name=5><FONT size=+1>LoopBack Plug</FONT>
  <HR>
  </A>
  <P></P>
  <P>
  <TABLE>
    <TBODY>
    <TR>
      <TD vAlign=top>
        <CENTER>
        <P><IMG alt="Loopback Plug" src="serial_files/loopback.gif"> <BR><FONT 
        size=-1>Figure 2 : Loopback Plug Wiring Diagram</FONT></CENTER></P></TD>
      <TD>This loopback plug can come in extremely handy when writing Serial / 
        RS232 Communications Programs. It has the receive and transmit lines 
        connected together, so that anything transmitted out of the Serial Port 
        is immediately received by the same port. If you connect this to a 
        Serial Port an load a Terminal Program, anything you type will be 
        immediately displayed on the screen. This can be used with the examples 
        later in this tutorial.<BR><BR><I>Please note that this is not intended 
        for use with Diagnostic Programs and thus will probably not work. For 
        these programs you require a differently wired Loop Back plug which may 
        vary from program to program.</I> </TD></TR></TBODY></TABLE></P>
  <P><A name=6><FONT size=+1>DTE / DCE Speeds</FONT>
  <HR>
  </A>
  <P></P>
  <P>We have already talked briefly about DTE &amp; DCE. A typical Data Terminal 
  Device is a computer and a typical Data Communications Device is a Modem. 
  Often people will talk about DTE to DCE or DCE to DCE speeds. DTE to DCE is 
  the speed between your modem and computer, sometimes referred to as your 
  terminal speed. This should run at faster speeds than the DCE to DCE speed. 
  DCE to DCE is the link between modems, sometimes called the line speed. </P>
  <P>Most people today will have 28.8K or 33.6K modems. Therefore we should 
  expect the DCE to DCE speed to be either 28.8K or 33.6K. Considering the high 
  speed of the modem we should expect the DTE to DCE speed to be about 115,200 
  BPS.(Maximum Speed of the 16550a UART) This is where some people often fall 
  into a trap. The communications program which they use have settings for DCE 
  to DTE speeds. However they see 9.6 KBPS, 14.4 KBPS etc and think it is your 
  modem speed. </P>
  <P>Today's Modems should have Data Compression build into them. This is very 
  much like PK-ZIP but the software in your modem compresses and decompresses 
  the data. When set up correctly you can expect compression ratios of 1:4 or 
  even higher. 1 to 4 compression would be typical of a text file. If we were 
  transferring that text file at 28.8K (DCE-DCE), then when the modem compresses 
  it you are actually transferring 115.2 KBPS between computers and thus have a 
  DCE-DTE speed of 115.2 KBPS. Thus this is why the DCE-DTE should be much 
  higher than your modem's connection speed.</P>
  <P>Some modem manufacturers quote a maximum compression ratio as 1:8. Lets say 
  for example its on a new 33.6 KBPS modem then we may get a maximum 268,800 BPS 
  transfer between modem and UART. If you only have a 16550a which can do 
  115,200 BPS tops, then you would be missing out on a extra bit of performance. 
  Buying a 16C650 should fix your problem with a maximum transfer rate of 
  230,400 BPS.</P>
  <P>However don't abuse your modem if you don't get these rates. These are 
  MAXIMUM compression ratios. In some instances if you try to send a already 
  compressed file, your modem can spend more time trying the compress it, thus 
  you get a transmission speed less than your modem's connection speed. If this 
  occurs try turning off your data compression. This should be fixed on newer 
  modems. Some files compress easier than others thus any file which compresses 
  easier is naturally going to have a higher compression ratio.</P>
  <P><A name=7><FONT size=+1>Flow Control</FONT>
  <HR>
  </A>
  <P></P>
  <P>So if our DTE to DCE speed is several times faster than our DCE to DCE 
  speed the PC can send data to your modem at 115,200 BPS. Sooner or later data 
  is going to get lost as buffers overflow, thus flow control is used. Flow 
  control has two basic varieties, Hardware or Software.</P>
  <P>Software flow control, sometimes expressed as Xon/Xoff uses two characters 
  Xon and Xoff. Xon is normally indicated by the ASCII 17 character where as the 
  ASCII 19 character is used for Xoff. The modem will only have a small buffer 
  so when the computer fills it up the modem sends a Xoff character to tell the 
  computer to stop sending data. Once the modem has room for more data it then 
  sends a Xon character and the computer sends more data. This type of flow 
  control has the advantage that it doesn't require any more wires as the 
  characters are sent via the TD/RD lines. However on slow links each character 
  requires 10 bits which can slow communications down.</P>
  <P>Hardware flow control is also known as RTS/CTS flow control. It uses two 
  wires in your serial cable rather than extra characters transmitted in your 
  data lines. Thus hardware flow control will not slow down transmission times 
  like Xon-Xoff does. When the computer wishes to send data it takes active the 
  Request to Send line. If the modem has room for this data, then the modem will 
  reply by taking active the Clear to Send line and the computer starts sending 
  data. If the modem does not have the room then it will not send a Clear to 
  Send.</P>
  <P><A name=8><FONT size=+1>The UART (8250 and Compatibles)</FONT>
  <HR>
  </A>
  <P></P>
  <P>UART stands for Universal Asynchronous Receiver / Transmitter. Its the 
  little box of tricks found on your serial card which plays the little games 
  with your modem or other connected devices. Most cards will have the UART's 
  integrated into other chips which may also control your parallel port, games 
  port, floppy or hard disk drives and are typically surface mount devices. The 
  8250 series, which includes the 16450, 16550, 16650, &amp; 16750 UARTS are the 
  most commonly found type in your PC. Later we will look at other types which 
  can be used in your homemade devices and projects. </P>
  <CENTER>
  <P><IMG height=293 alt="Pin Diagrams of UARTs - 16550, 16450 &amp; 8250" 
  src="serial_files/uart.gif" width=520> <BR><FONT size=-1>Figure 3 : Pin 
  Diagrams for 16550, 16450 &amp; 8250 UARTs</FONT></P></CENTER>
  <P>The 16550 is chip compatible with the 8250 &amp; 16450. The only two 
  differences are pins 24 &amp; 29. On the 8250 Pin 24 was chip select out which 
  functioned only as a indicator to if the chip was active or not. Pin 29 was 
  not connected on the 8250/16450 UARTs. The 16550 introduced two new pins in 
  their place. These are Transmit Ready and Receive Ready which can be 
  implemented with DMA (Direct Memory Access). These Pins have two different 
  modes of operation. Mode 0 supports single transfer DMA where as Mode 1 
  supports Multi-transfer DMA. </P>
  <P>Mode 0 is also called the 16450 mode. This mode is selected when the FIFO 
  buffers are disabled via Bit 0 of the FIFO Control Register or When the FIFO 
  buffers are enabled but DMA Mode Select = 0. (Bit 3 of FCR) In this mode RXRDY 
  is active low when at least one character (Byte) is present in the Receiver 
  Buffer. RXRDY will go inactive high when no more characters are left in the 
  Receiver Buffer. TXRDY will be active low when there are no characters in the 
  Transmit Buffer. It will go inactive high after the first character / byte is 
  loaded into the Transmit Buffer. </P>
  <P>Mode 1 is when the FIFO buffers are active and the DMA Mode Select = 1. In 
  Mode 1, RXRDY will go active low when the trigger level is reached or when 
  16550 Time Out occurs and will return to inactive state when no more 
  characters are left in the FIFO. TXRDY will be active when no characters are 
  present in the Transmit Buffer and will go inactive when the FIFO Transmit 
  Buffer is completely Full. </P>
  <P>All the UARTs pins are TTL compatible. That includes TD, RD, RI, DCD, DSR, 
  CTS, DTR and RTS which all interface into your serial plug, typically a D-type 
  connector. Therefore RS232 Level Converters (which we talk about in detail 
  later) are used. These are commonly the DS1489 Receiver and the DS1488 as the 
  PC has +12 and -12 volt rails which can be used by these devices. The RS232 
  Converters will convert the TTL signal into RS232 Logic Levels. </P>
  <CENTER>
  <TABLE width="80%" border=1>
    <TBODY>
    <TR>
      <TD width="10%">
        <CENTER><B>Pin No.</B></CENTER></TD>
      <TD width="15%">
        <CENTER><B>Name</B></CENTER></TD>
      <TD><B>Notes</B></TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 1:8</CENTER></TD>
      <TD>
        <CENTER>D0:D7</CENTER></TD>
      <TD>Data Bus</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 9</CENTER></TD>
      <TD>
        <CENTER>RCLK</CENTER></TD>
      <TD>Receiver Clock Input. The frequency of this input should equal the 
        receivers baud rate * 16</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 10</CENTER></TD>
      <TD>
        <CENTER>RD</CENTER></TD>
      <TD>Receive Data</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 11</CENTER></TD>
      <TD>
        <CENTER>TD</CENTER></TD>
      <TD>Transmit Data</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 12</CENTER></TD>
      <TD>
        <CENTER>CS0</CENTER></TD>
      <TD>Chip Select 0 - Active High</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 13</CENTER></TD>
      <TD>
        <CENTER>CS1</CENTER></TD>
      <TD>Chip Select 1 - Active High</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 14</CENTER></TD>
      <TD>
        <CENTER>nCS2</CENTER></TD>
      <TD>Chip Select 2 - Active Low</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 15</CENTER></TD>
      <TD>
        <CENTER>nBAUDOUT</CENTER></TD>
      <TD>Baud Output - Output from Programmable Baud Rate Generator. 
        Frequency = (Baud Rate x 16)</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 16</CENTER></TD>
      <TD>
        <CENTER>XIN</CENTER></TD>
      <TD>External Crystal Input - Used for Baud Rate Generator 
    Oscillator</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 17</CENTER></TD>
      <TD>
        <CENTER>XOUT</CENTER></TD>
      <TD>External Crystal Output</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 18</CENTER></TD>
      <TD>
        <CENTER>nWR</CENTER></TD>
      <TD>Write Line - Inverted</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 19</CENTER></TD>
      <TD>
        <CENTER>WR</CENTER></TD>
      <TD>Write Line - Not Inverted</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 20</CENTER></TD>
      <TD>
        <CENTER>VSS</CENTER></TD>
      <TD>Connected to Common Ground</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 21</CENTER></TD>
      <TD>
        <CENTER>RD</CENTER></TD>
      <TD>Read Line - Inverted</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 22</CENTER></TD>
      <TD>
        <CENTER>nRD</CENTER></TD>
      <TD>Read Line - Not Inverted</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 23</CENTER></TD>
      <TD>
        <CENTER>DDIS</CENTER></TD>
      <TD>Driver Disable. This pin goes low when CPU is reading from UART. Can 
        be connected to Bus Transceiver in case of high capacity data bus.</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 24</CENTER></TD>
      <TD>
        <CENTER>nTXRDY</CENTER></TD>
      <TD>Transmit Ready</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 25</CENTER></TD>
      <TD>
        <CENTER>nADS</CENTER></TD>
      <TD>Address Strobe. Used if signals are not stable during read or write 
        cycle</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 26</CENTER></TD>
      <TD>
        <CENTER>A2</CENTER></TD>
      <TD>Address Bit 2</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 27</CENTER></TD>
      <TD>
        <CENTER>A1</CENTER></TD>
      <TD>Address Bit 1</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 28</CENTER></TD>
      <TD>
        <CENTER>A0</CENTER></TD>
      <TD>Address Bit 0</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 29</CENTER></TD>
      <TD>
        <CENTER>nRXRDY</CENTER></TD>
      <TD>Receive Ready</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 30</CENTER></TD>
      <TD>
        <CENTER>INTR</CENTER></TD>
      <TD>Interrupt Output</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 31</CENTER></TD>
      <TD>
        <CENTER>nOUT2</CENTER></TD>
      <TD>User Output 2</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 32</CENTER></TD>
      <TD>
        <CENTER>nRTS</CENTER></TD>
      <TD>Request to Send</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 33</CENTER></TD>
      <TD>
        <CENTER>nDTR</CENTER></TD>
      <TD>Data Terminal Ready</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 34</CENTER></TD>
      <TD>
        <CENTER>nOUT1</CENTER></TD>
      <TD>User Output 1</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 35</CENTER></TD>
      <TD>
        <CENTER>MR</CENTER></TD>
      <TD>Master Reset</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 36</CENTER></TD>
      <TD>
        <CENTER>nCTS</CENTER></TD>
      <TD>Clear To Send</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 37</CENTER></TD>
      <TD>
        <CENTER>nDSR</CENTER></TD>
      <TD>Data Set Ready</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 38</CENTER></TD>
      <TD>
        <CENTER>nDCD</CENTER></TD>
      <TD>Data Carrier Detect</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 39</CENTER></TD>
      <TD>
        <CENTER>nRI</CENTER></TD>
      <TD>Ring Indicator</TD></TR>
    <TR>
      <TD>
        <CENTER>Pin 40</CENTER></TD>
      <TD>
        <CENTER>VDD</CENTER></TD>
      <TD>+ 5 Volts</TD></TR></TBODY></TABLE><FONT size=-1>
  <CENTER>Table 2 : Pin Assignments for 16550A UART</CENTER></FONT></CENTER>
  <P>The UART requires a Clock to run. If you look at your serial card a common 
  crystal found is either a 1.8432 MHZ or a 18.432 MHZ Crystal. The crystal in 
  connected to the XIN-XOUT pins of the UART using a few extra components which 
  help the crystal to start oscillating. This clock will be used for the 
  Programmable Baud Rate Generator which directly interfaces into the transmit 
  timing circuits but not directly into the receiver timing circuits. For this 
  an external connection mast be made from pin 15 (BaudOut) to pin 9 (Receiver 
  clock in.) Note that the clock signal will be at Baudrate * 16. </P>
  <P>If you are serious about pursuing the 16550 UART used in your PC further, 
  then would suggest downloading a copy of the PC16550D data sheet from <A 
  href="http://www.natsemi.com/">National Semiconductors Site</A>. Data sheets 
  are available in .PDF format so you will need Adobe Acrobat Reader to read 
  these. <A href="http://www.ti.com/">Texas Instruments</A> has released the 
  16750 UART which has 64 Byte FIFO's. Data Sheets for the TL16C750 are 
  available from the Texas Instruments Site. </P>
  <P><A name=9><FONT size=+1>Types of UARTS (For PC's)</FONT>
  <HR>
  </A>
  <P></P>
  <UL>
    <TABLE>
      <TBODY>
      <TR>
        <TD vAlign=top width="10%">8250</TD>
        <TD>First UART in this series. It contains no scratch register. The 
          8250A was an improved version of the 8250 which operates faster on the 
          bus side. </TD></TR>
      <TR>
        <TD vAlign=top width="10%">8250A</TD>
        <TD>This UART is faster than the 8250 on the bus side. Looks exactly 
          the same to software than 16450.</TD></TR>
      <TR>
        <TD vAlign=top width="10%">8250B</TD>
        <TD>Very similar to that of the 8250 UART.</TD></TR>
      <TR>
        <TD vAlign=top width="10%">16450</TD>
        <TD>Used in AT's (Improved bus speed over 8250's). Operates 
          comfortably at 38.4KBPS. Still quite common today.</TD></TR>
      <TR>
        <TD vAlign=top width="10%">16550</TD>
        <TD>This was the first generation of buffered UART. It has a 16 byte 
          buffer, however it doesn't work and is replaced with the 16550A.</TD></TR>
      <TR>
        <TD vAlign=top width="10%">16550A</TD>
        <TD>Is the most common UART use for high speed communications eg 14.4K 
          &amp; 28.8K Modems. They made sure the FIFO buffers worked on this 
          UART.</TD></TR>
      <TR>
        <TD vAlign=top width="10%">16650</TD>
        <TD>Very recent breed of UART. Contains a 32 byte FIFO, Programmable 
          X-On / X-Off characters and supports power management.</TD></TR>
      <TR>
        <TD vAlign=top width="10%">16750</TD>
        <TD>Produced by Texas Instruments. Contains a 64 byte 
      FIFO.</TD></TR></TBODY></TABLE><BR></UL></UL><A name=part2></A>
<HR>
<I><FONT size=+2>Part Two : Serial Port's Registers (PC's)</FONT></I>
<HR>

<P></P>
<UL>
  <P><A name=12><FONT size=+1>Port Addresses &amp; IRQ's</FONT><BR>
  <HR>
  </A>
  <P></P>
  <CENTER>
  <TABLE width="60%" border=1>
    <TBODY>
    <TR>
      <TD>
        <CENTER><B>Name </B></CENTER></TD>
      <TD>
        <CENTER><B>Address</B></CENTER></TD>
      <TD>
        <CENTER><B>IRQ</B></CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>COM 1 </CENTER></TD>
      <TD>
        <CENTER>3F8 </CENTER></TD>
      <TD>
        <CENTER>4</CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>COM 2 </CENTER></TD>
      <TD>
        <CENTER>2F8 </CENTER></TD>
      <TD>
        <CENTER>3</CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>COM 3 </CENTER></TD>
      <TD>
        <CENTER>3E8 </CENTER></TD>
      <TD>
        <CENTER>4</CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>COM 4 </CENTER></TD>
      <TD>
        <CENTER>2E8 </CENTER></TD>
      <TD>
        <CENTER>3</CENTER></TD></TR></TBODY></TABLE><FONT size=-1>Table 3 : Standard 
  Port Addresses </FONT></CENTER>
  <P>Above is the standard port addresses. These should work for most P.C's. If 
  you just happen to be lucky enough to own a IBM P/S2 which has a micro-channel 
  bus, then expect a different set of addresses and IRQ's. Just like the LPT 
  ports, the base addresses for the COM ports can be read from the BIOS Data 
  Area. </P>
  <CENTER>
  <TABLE width="60%" border=1>
    <TBODY>
    <TR>
      <TD width="40%"><B>
        <CENTER>Start Address</CENTER><B></B></B></TD>
      <TD width="60%"><B>
        <CENTER>Function</CENTER><B></B></B></TD></TR>
    <TR>
      <TD>
        <CENTER>0000:0400</CENTER></TD>
      <TD>COM1's Base Address</TD></TR>
    <TR>
      <TD>
        <CENTER>0000:0402</CENTER></TD>
      <TD>COM2's Base Address</TD></TR>
    <TR>
      <TD>
        <CENTER>0000:0404</CENTER></TD>
      <TD>COM3's Base Address</TD></TR>
    <TR>
      <TD>
        <CENTER>0000:0406</CENTER></TD>
      <TD>COM4's Base Address</TD></TR></TBODY></TABLE><FONT size=-1>Table 4 - COM 
  Port Addresses in the BIOS Data Area;</FONT></CENTER>
  <P>The above table shows the address at which we can find the Communications 
  (COM) ports addresses in the BIOS Data Area. Each address will take up 2 
  bytes. The following sample program in C, shows how you can read these 
  locations to obtain the addresses of your communications ports. </P>
  <UL><PRE>#include &lt;stdio.h&gt;
#include &lt;dos.h&gt;

void main(void)
{
 unsigned int far *ptraddr;  /* Pointer to location of Port Addresses */
 unsigned int address;       /* Address of Port */
 int a;

 ptraddr=(unsigned int far *)0x00000400;

 for (a = 0; a &lt;  4; a++)
   {
    address = *ptraddr;
    if (address == 0)
                printf("No port found for COM%d \n",a+1);
    else
                printf("Address assigned to COM%d is %Xh\n",a+1,address);
    *ptraddr++;
   }
}
</PRE></UL>
  <P><A name=13><FONT size=+1>Table of Registers</FONT><BR>
  <HR>
  </A>
  <P></P>
  <P>
  <CENTER>
  <TABLE border=1>
    <TBODY>
    <TR>
      <TD>
        <CENTER><B>Base Address</B></CENTER></TD>
      <TD>
        <CENTER><B>DLAB</B></CENTER></TD>
      <TD>
        <CENTER><B>Read/Write</B></CENTER></TD>
      <TD>
        <CENTER><B>Abr. </B></CENTER></TD>
      <TD>
        <CENTER><B>Register Name </B></CENTER></TD></TR>
    <TR>
      <TD rowSpan=3>
        <CENTER>+ 0</CENTER></TD>
      <TD>
        <CENTER>=0</CENTER></TD>
      <TD>
        <CENTER>Write</CENTER></TD>
      <TD>
        <CENTER>- </CENTER></TD>
      <TD>
        <CENTER>Transmitter Holding Buffer </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>=0</CENTER></TD>
      <TD>
        <CENTER>Read</CENTER></TD>
      <TD>
        <CENTER>- </CENTER></TD>
      <TD>
        <CENTER>Receiver Buffer </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>=1</CENTER></TD>
      <TD>
        <CENTER>Read/Write</CENTER></TD>
      <TD>
        <CENTER>- </CENTER></TD>
      <TD>
        <CENTER>Divisor Latch Low Byte </CENTER></TD></TR>
    <TR>
      <TD rowSpan=2>
        <CENTER>+ 1</CENTER></TD>
      <TD>
        <CENTER>=0</CENTER></TD>
      <TD>
        <CENTER>Read/Write</CENTER></TD>
      <TD>
        <CENTER>IER </CENTER></TD>
      <TD>
        <CENTER>Interrupt Enable Register </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>=1</CENTER></TD>
      <TD>
        <CENTER>Read/Write</CENTER></TD>
      <TD>
        <CENTER>- </CENTER></TD>
      <TD>
        <CENTER>Divisor Latch High Byte </CENTER></TD></TR>
    <TR>
      <TD rowSpan=2>
        <CENTER>+ 2</CENTER></TD>
      <TD>
        <CENTER>-</CENTER></TD>
      <TD>
        <CENTER>Read</CENTER></TD>
      <TD>
        <CENTER>IIR </CENTER></TD>
      <TD>
        <CENTER>Interrupt Identification Register</CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>-</CENTER></TD>
      <TD>
        <CENTER>Write</CENTER></TD>
      <TD>
        <CENTER>FCR </CENTER></TD>
      <TD>
        <CENTER>FIFO Control Register </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>+ 3</CENTER></TD>
      <TD>
        <CENTER>-</CENTER></TD>
      <TD>
        <CENTER>Read/Write</CENTER></TD>
      <TD>
        <CENTER>LCR </CENTER></TD>
      <TD>
        <CENTER>Line Control Register </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>+ 4</CENTER></TD>
      <TD>
        <CENTER>-</CENTER></TD>
      <TD>
        <CENTER>Read/Write</CENTER></TD>
      <TD>
        <CENTER>MCR </CENTER></TD>
      <TD>
        <CENTER>Modem Control Register </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>+ 5</CENTER></TD>
      <TD>
        <CENTER>-</CENTER></TD>
      <TD>
        <CENTER>Read</CENTER></TD>
      <TD>
        <CENTER>LSR </CENTER></TD>
      <TD>
        <CENTER>Line Status Register </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>+ 6</CENTER></TD>
      <TD>
        <CENTER>-</CENTER></TD>
      <TD>
        <CENTER>Read</CENTER></TD>
      <TD>
        <CENTER>MSR </CENTER></TD>
      <TD>
        <CENTER>Modem Status Register </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>+ 7</CENTER></TD>
      <TD>
        <CENTER>-</CENTER></TD>
      <TD>
        <CENTER>Read/Write</CENTER></TD>
      <TD>
        <CENTER>- </CENTER></TD>
      <TD>
        <CENTER>Scratch Register </CENTER></TD></TR></TBODY></TABLE><FONT size=-1>
  <CENTER>Table 5 : Table of Registers</CENTER></FONT></CENTER>
  <P></P>
  <P><A name=14><FONT size=+1>DLAB ?</FONT><BR>
  <HR>
  </A>
  <P></P>
  <P>You will have noticed in the table of registers that there is a DLAB 
  column. When DLAB is set to '0' or '1' some of the registers change. This is 
  how the UART is able to have 12 registers (including the scratch register) 
  through only 8 port addresses. DLAB stands for Divisor Latch Access Bit. When 
  DLAB is set to '1' via the line control register, two registers become 
  available from which you can set your speed of communications measured in bits 
  per second.</P>
  <P>The UART will have a crystal which should oscillate around 1.8432 MHZ. The 
  UART incorporates a divide by 16 counter which simply divides the incoming 
  clock signal by 16. Assuming we had the 1.8432 MHZ clock signal, that would 
  leave us with a maximum, 115,200 hertz signal making the UART capable of 
  transmitting and receiving at 115,200 Bits Per Second (BPS). That would be 
  fine for some of the faster modems and devices which can handle that speed, 
  but others just wouldn't communicate at all. Therefore the UART is fitted with 
  a Programmable Baud Rate Generator which is controlled by two registers.</P>
  <P>Lets say for example we only wanted to communicate at 2400 BPS. We worked 
  out that we would have to divide 115,200 by 48 to get a workable 2400 Hertz 
  Clock. The "Divisor", in this case 48, is stored in the two registers 
  controlled by the "Divisor Latch Access Bit". This divisor can be any number 
  which can be stored in 16 bits (ie 0 to 65535). The UART only has a 8 bit data 
  bus, thus this is where the two registers are used. The first register (Base + 
  0) when DLAB = 1 stores the "Divisor latch low byte" where as the second 
  register (base + 1 when DLAB = 1) stores the "Divisor latch high byte."</P>
  <P>Below is a table of some more common speeds and their divisor latch high 
  bytes &amp; low bytes. Note that all the divisors are shown in 
Hexadecimal.</P>
  <P>
  <CENTER>
  <TABLE border=1>
    <TBODY>
    <TR>
      <TD>
        <CENTER><B>Speed (BPS) </B></CENTER></TD>
      <TD>
        <CENTER><B>Divisor (Dec) </B></CENTER></TD>
      <TD>
        <CENTER><B>Divisor Latch High Byte </B></CENTER></TD>
      <TD>
        <CENTER><B>Divisor Latch Low Byte </B></CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>50 </CENTER></TD>
      <TD>
        <CENTER>2304 </CENTER></TD>
      <TD>
        <CENTER>09h </CENTER></TD>
      <TD>
        <CENTER>00h </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>300 </CENTER></TD>
      <TD>
        <CENTER>384 </CENTER></TD>
      <TD>
        <CENTER>01h </CENTER></TD>
      <TD>
        <CENTER>80h </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>600 </CENTER></TD>
      <TD>
        <CENTER>192 </CENTER></TD>
      <TD>
        <CENTER>00h </CENTER></TD>
      <TD>
        <CENTER>C0h </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>2400 </CENTER></TD>
      <TD>
        <CENTER>48 </CENTER></TD>
      <TD>
        <CENTER>00h </CENTER></TD>
      <TD>
        <CENTER>30h </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>4800 </CENTER></TD>
      <TD>
        <CENTER>24 </CENTER></TD>
      <TD>
        <CENTER>00h </CENTER></TD>
      <TD>
        <CENTER>18h </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>9600 </CENTER></TD>
      <TD>
        <CENTER>12 </CENTER></TD>
      <TD>
        <CENTER>00h </CENTER></TD>
      <TD>
        <CENTER>0Ch </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>19200 </CENTER></TD>
      <TD>
        <CENTER>6 </CENTER></TD>
      <TD>
        <CENTER>00h </CENTER></TD>
      <TD>
        <CENTER>06h </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>38400 </CENTER></TD>
      <TD>
        <CENTER>3 </CENTER></TD>
      <TD>
        <CENTER>00h </CENTER></TD>
      <TD>
        <CENTER>03h </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>57600 </CENTER></TD>
      <TD>
        <CENTER>2 </CENTER></TD>
      <TD>
        <CENTER>00h </CENTER></TD>
      <TD>
        <CENTER>02h </CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>115200 </CENTER></TD>
      <TD>
        <CENTER>1 </CENTER></TD>
      <TD>
        <CENTER>00h </CENTER></TD>
      <TD>
        <CENTER>01h </CENTER></TD></TR></TBODY></TABLE><FONT size=-1>Table 6 : Table 
  of Commonly Used Baudrate Divisors</FONT> </CENTER>
  <P></P>
  <P><A name=15></A><FONT size=+1>Interrupt Enable Register (IER)</FONT></I><BR>
  <HR>

  <P></P>
  <P>
  <CENTER>
  <TABLE width="80%" border=1>
    <TBODY>
    <TR>
      <TD>
        <CENTER><B>Bit</B></CENTER></TD>
      <TD>
        <CENTER><B>Notes</B></CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 7</CENTER></TD>
      <TD>Reserved</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 6</CENTER></TD>
      <TD>Reserved</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 5</CENTER></TD>
      <TD>Enables Low Power Mode (16750)</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 4</CENTER></TD>
      <TD>Enables Sleep Mode (16750)</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 3</CENTER></TD>
      <TD>Enable Modem Status Interrupt</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 2</CENTER></TD>
      <TD>Enable Receiver Line Status Interrupt</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 1</CENTER></TD>
      <TD>Enable Transmitter Holding Register Empty Interrupt</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 0</CENTER></TD>
      <TD>Enable Received Data Available Interrupt</TD></TR></TBODY></TABLE><FONT 
  size=-1>
  <CENTER>Table 7 : Interrupt Enable Register</CENTER></FONT></CENTER>
  <P></P>
  <P>The Interrupt Enable Register could possibly be one of the easiest 
  registers on a UART to understand. Setting Bit 0 high enables the Received 
  Data Available Interrupt which generates an interrupt when the receiving 
  register/FIFO contains data to be read by the CPU. </P>
  <P>Bit 1 enables Transmit Holding Register Empty Interrupt. This interrupts 
  the CPU when the transmitter buffer is empty. Bit 2 enables the receiver line 
  status interrupt. The UART will interrupt when the receiver line status 
  changes. Likewise for bit 3 which enables the modem status interrupt. Bits 4 
  to 7 are the easy ones. They are simply reserved. (If only everything was that 
  easy!) </P>
  <P><A name=16><FONT size=+1>Interrupt Identification Register (IIR)</FONT><BR>
  <HR>
  </A>
  <P></P>
  <P>
  <CENTER>
  <TABLE width="80%" border=1>
    <TBODY>
    <TR>
      <TD>
        <CENTER><B>Bit</B></CENTER></TD>
      <TD colSpan=3>
        <CENTER><B>Notes</B></CENTER></TD></TR>
    <TR>
      <TD vAlign=top rowSpan=4>
        <CENTER>Bits 6 and 7</CENTER></TD>
      <TD>
        <CENTER>Bit 6</CENTER></TD>
      <TD>
        <CENTER>Bit 7</CENTER></TD>
      <TD>&nbsp;</TD></TR>
    <TR>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>No FIFO </TD></TR>
    <TR>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>FIFO Enabled but Unusable </TD></TR>
    <TR>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>FIFO Enabled </TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 5</CENTER></TD>
      <TD colSpan=3>64 Byte Fifo Enabled (16750 only)</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 4</CENTER></TD>
      <TD colSpan=3>Reserved</TD></TR>
    <TR>
      <TD vAlign=top rowSpan=2>
        <CENTER>Bit 3</CENTER></TD>
      <TD>
        <CENTER>0</CENTER>
      <TD colSpan=2>Reserved on 8250, 16450</TD></TR>
    <TR>
      <TD>
        <CENTER>1</CENTER>
      <TD colSpan=2>16550 Time-out Interrupt Pending</TD></TR>
    <TR>
      <TD vAlign=top rowSpan=5>
        <CENTER>Bits 1 and 2</CENTER></TD>
      <TD>
        <CENTER>Bit 2</CENTER></TD>
      <TD>
        <CENTER>Bit 1</CENTER></TD>
      <TD>&nbsp; </TD></TR>
    <TR>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>Modem Status Interrupt </TD></TR>
    <TR>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>Transmitter Holding Register Empty Interrupt</TD></TR>
    <TR>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>Received Data Available Interrupt</TD></TR>
    <TR>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>Receiver Line Status Interrupt</TD></TR>
    <TR>
      <TD vAlign=top rowSpan=2>
        <CENTER>Bit 0</CENTER></TD>
      <TD>
        <CENTER>0</CENTER>
      <TD colSpan=2>Interrupt Pending</TD></TR>
    <TR>
      <TD>
        <CENTER>1</CENTER>
      <TD colSpan=2>No Interrupt Pending</TD></TR></TBODY></TABLE><FONT size=-1>
  <CENTER>Table 8 : Interrupt Identification Register </CENTER></FONT></CENTER>
  <P>The interrupt identification register is a read only register. Bits 6 and 7 
  give status on the FIFO Buffer. When both bits are '0' no FIFO buffers are 
  active. This should be the only result you will get from a 8250 or 16450. If 
  bit 7 is active but bit 6 is not active then the UART has it's buffers enabled 
  but are unusable. This occurs on the 16550 UART where a bug in the FIFO buffer 
  made the FIFO's unusable. If both bits are '1' then the FIFO buffers are 
  enabled and fully operational. </P>
  <P>Bits 4 and 5 are reserved. Bit 3 shows the status of the time-out interrupt 
  on a 16550 or higher. </P>
  <P>Lets jump to Bit 0 which shows whether an interrupt has occurred. If an 
  interrupt has occurred it's status will shown by bits 1 and 2. These 
  interrupts work on a priority status. The Line Status Interrupt has the 
  highest Priority, followed by the Data Available Interrupt, then the Transmit 
  Register Empty Interrupt and then the Modem Status Interrupt which has the 
  lowest priority. </P>
  <P></P>
  <P><A name=17></A><FONT size=+1>First In / First Out Control Register 
  (FCR)</FONT><BR>
  <HR>

  <P></P>
  <P>
  <CENTER>
  <TABLE width="80%" border=1>
    <TBODY>
    <TR>
      <TD>
        <CENTER><B>Bit</B></CENTER></TD>
      <TD colSpan=3>
        <CENTER><B>Notes</B></CENTER></TD></TR>
    <TR>
      <TD vAlign=top rowSpan=5>
        <CENTER>Bits 6 and 7</CENTER></TD>
      <TD>
        <CENTER>Bit 7</CENTER></TD>
      <TD>
        <CENTER>Bit 6</CENTER></TD>
      <TD>Interrupt Trigger Level </TD></TR>
    <TR>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>1 Byte </TD></TR>
    <TR>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>4 Bytes </TD></TR>
    <TR>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>8 Bytes </TD></TR>
    <TR>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>14 Bytes</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 5</CENTER></TD>
      <TD colSpan=3>Enable 64 Byte FIFO (16750 only)</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 4</CENTER></TD>
      <TD colSpan=3>Reserved</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 3</CENTER></TD>
      <TD colSpan=3>DMA Mode Select. Change status of RXRDY &amp; TXRDY pins 
        from mode 1 to mode 2.</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 2</CENTER></TD>
      <TD colSpan=3>Clear Transmit FIFO</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 1</CENTER></TD>
      <TD colSpan=3>Clear Receive FIFO</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 0</CENTER></TD>
      <TD colSpan=3>Enable FIFO's</TD></TR></TBODY></TABLE><FONT size=-1>
  <CENTER>Table 9 : FIFO Control Register </CENTER></FONT></CENTER>
  <P></P>
  <P>The FIFO register is a write only register. This register is used to 
  control the FIFO (First In / First Out) buffers which are found on 16550's and 
  higher. </P>
  <P>Bit 0 enables the operation of the receive and transmit FIFO's. Writing a 
  '0' to this bit will disable the operation of transmit and receive FIFO's, 
  thus you will loose all data stored in these FIFO buffers. </P>
  <P>Bit's 1 and 2 control the clearing of the transmit or receive FIFO's. Bit 1 
  is responsible for the receive buffer while bit 2 is responsible for the 
  transmit buffer. Setting these bits to 1 will only clear the contents of the 
  FIFO and will not affect the shift registers. These two bits are self 
  resetting, thus you don't need to set the bits to '0' when finished. </P>Bit 3 
  enables the DMA mode select which is found on 16550 UARTs and higher. More on 
  this later. Bits 4 and 5 are those easy type again, Reserved. 
  <P></P>
  <P>Bits 6 and 7 are used to set the triggering level on the Receive FIFO. For 
  example if bit 7 was set to '1' and bit 6 was set to '0' then the trigger 
  level is set to 8 bytes. When there is 8 bytes of data in the receive FIFO 
  then the Received Data Available interrupt is set. See (IIR) </P>
  <P><A name=18></A><FONT size=+1>Line Control Register (LCR)</FONT><BR>
  <HR>

  <P></P>
  <P>
  <CENTER>
  <TABLE width="80%" border=1>
    <TBODY>
    <TR>
      <TD vAlign=top rowSpan=2>
        <CENTER>Bit 7</CENTER></TD>
      <TD>
        <CENTER>1</CENTER>
      <TD colSpan=3>Divisor Latch Access Bit</TD></TR>
    <TR>
      <TD>
        <CENTER>0</CENTER>
      <TD colSpan=3>Access to Receiver buffer, Transmitter buffer &amp; 
        Interrupt Enable Register</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 6</CENTER></TD>
      <TD colSpan=4>Set Break Enable</TD></TR>
    <TR>
      <TD vAlign=top rowSpan=6>
        <CENTER>Bits 3, 4 And 5</CENTER></TD>
      <TD width="8%">
        <CENTER>Bit 5</CENTER></TD>
      <TD width="8%">
        <CENTER>Bit 4</CENTER></TD>
      <TD width="8%">
        <CENTER>Bit 3</CENTER></TD>
      <TD>Parity Select</TD></TR>
    <TR>
      <TD>
        <CENTER>X</CENTER></TD>
      <TD>
        <CENTER>X</CENTER></TD>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>No Parity </TD></TR>
    <TR>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>Odd Parity </TD></TR>
    <TR>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>Even Parity </TD></TR>
    <TR>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>High Parity (Sticky)</TD></TR>
    <TR>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>Low Parity (Sticky)</TD></TR>
    <TR>
      <TD vAlign=top rowSpan=3>
        <CENTER>Bit 2</CENTER></TD>
      <TD colSpan=4>Length of Stop Bit</TD></TR>
    <TR>
      <TD>
        <CENTER>0</CENTER>
      <TD colSpan=3>One Stop Bit</TD></TR>
    <TR>
      <TD>
        <CENTER>1</CENTER>
      <TD colSpan=3>2 Stop bits for words of length 6,7 or 8 bits or 1.5 Stop 
        Bits for Word lengths of 5 bits.</TD></TR>
    <TR>
      <TD vAlign=top rowSpan=5>
        <CENTER>Bits 0 And 1</CENTER></TD>
      <TD>
        <CENTER>Bit 1</CENTER></TD>
      <TD>
        <CENTER>Bit 0</CENTER></TD>
      <TD colSpan=2>Word Length</TD></TR>
    <TR>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD colSpan=2>5 Bits </TD></TR>
    <TR>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD colSpan=2>6 Bits </TD></TR>
    <TR>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>
        <CENTER>0</CENTER></TD>
      <TD colSpan=2>7 Bits </TD></TR>
    <TR>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD>
        <CENTER>1</CENTER></TD>
      <TD colSpan=2>8 Bits </TD></TR></TBODY></TABLE><FONT size=-1>
  <CENTER>Table 10 : Line Control Register </CENTER></FONT></CENTER>
  <P></P>
  <P>The Line Control register sets the basic parameters for communication. Bit 
  7 is the Divisor Latch Access Bit or DLAB for short. We have already talked 
  about what it does. (See DLAB?) Bit 6 Sets break enable. When active, the TD 
  line goes into "Spacing" state which causes a break in the receiving UART. 
  Setting this bit to '0' Disables the Break.</P>
  <P>Bits 3,4 and 5 select parity. If you study the 3 bits, you will find that 
  bit 3 controls parity. That is, if it is set to '0' then no parity is used, 
  but if it is set to '1' then parity is used. Jumping to bit 5, we can see that 
  it controls sticky parity. Sticky parity is simply when the parity bit is 
  always transmitted and checked as a '1' or '0'. This has very little success 
  in checking for errors as if the first 4 bits contain errors but the sticky 
  parity bit contains the appropriately set bit, then a parity error will not 
  result. Sticky high parity is the use of a '1' for the parity bit, while the 
  opposite, sticky low parity is the use of a '0' for the parity bit. </P>
  <P>If bit 5 controls sticky parity, then turning this bit off must produce 
  normal parity provided bit 3 is still set to '1'. Odd parity is when the 
  parity bit is transmitted as a '1' or '0' so that there is a odd number of 
  1's. Even parity must then be the parity bit produces and even number of 1's. 
  This provides better error checking but still is not perfect, thus CRC-32 is 
  often used for software error correction. If one bit happens to be inverted 
  with even or odd parity set, then a parity error will occur, however if two 
  bits are flipped in such a way that it produces the correct parity bit then an 
  parity error will no occur. </P>
  <P>Bit 2 sets the length of the stop bits. Setting this bit to '0' will 
  produce one stop bit, however setting it to '1' will produce either 1.5 or 2 
  stop bits depending upon the word length. Note that the receiver only checks 
  the first stop bit. </P>
  <P>Bits 0 and 1 set the word length. This should be pretty straight forward. A 
  word length of 8 bits is most commonly used today. </P>
  <P><A name=19></A><FONT size=+1>Modem Control Register (MCR)</FONT><BR>
  <HR>

  <P></P>
  <P>
  <CENTER>
  <TABLE width="80%" border=1>
    <TBODY>
    <TR>
      <TD>
        <CENTER><B>Bit</B></CENTER></TD>
      <TD>
        <CENTER><B>Notes</B></CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 7</CENTER></TD>
      <TD>Reserved</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 6</CENTER></TD>
      <TD>Reserved</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 5</CENTER></TD>
      <TD>Autoflow Control Enabled (16750 only)</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 4</CENTER></TD>
      <TD>LoopBack Mode </TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 3</CENTER></TD>
      <TD>Aux Output 2</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 2</CENTER></TD>
      <TD>Aux Output 1</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 1</CENTER></TD>
      <TD>Force Request to Send</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 0</CENTER></TD>
      <TD>Force Data Terminal Ready</TD></TR></TBODY></TABLE><FONT size=-1>
  <CENTER>Table 11 : Modem Control Register </CENTER></FONT></CENTER>
  <P></P>
  <P>The Modem Control Register is a Read/Write Register. Bits 5,6 and 7 are 
  reserved. Bit 4 activates the loopback mode. In Loopback mode the transmitter 
  serial output is placed into marking state. The receiver serial input is 
  disconnected. The transmitter out is looped back to the receiver in. DSR, CTS, 
  RI &amp; DCD are disconnected. DTR, RTS, OUT1 &amp; OUT2 are connected to the 
  modem control inputs. The modem control output pins are then place in an 
  inactive state. In this mode any data which is placed in the transmitter 
  registers for output is received by the receiver circuitry on the same chip 
  and is available at the receiver buffer. This can be used to test the UARTs 
  operation.</P>
  <P>Aux Output 2 maybe connected to external circuitry which controls the 
  UART-CPU interrupt process. Aux Output 1 is normally disconnected, but on some 
  cards is used to switch between a 1.8432MHZ crystal to a 4MHZ crystal which is 
  used for MIDI. Bits 0 and 1 simply control their relevant data lines. For 
  example setting bit 1 to '1' makes the request to send line active. </P>
  <P><A name=20></A><FONT size=+1>Line Status Register (LSR)</FONT><BR>
  <HR>

  <P></P>
  <CENTER>
  <TABLE width="80%" border=1>
    <TBODY>
    <TR>
      <TD>
        <CENTER><B>Bit</B></CENTER></TD>
      <TD>
        <CENTER><B>Notes</B></CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 7</CENTER></TD>
      <TD>Error in Received FIFO</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 6</CENTER></TD>
      <TD>Empty Data Holding Registers </TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 5</CENTER></TD>
      <TD>Empty Transmitter Holding Register</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 4</CENTER></TD>
      <TD>Break Interrupt </TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 3</CENTER></TD>
      <TD>Framing Error</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 2</CENTER></TD>
      <TD>Parity Error</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 1</CENTER></TD>
      <TD>Overrun Error</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 0</CENTER></TD>
      <TD>Data Ready</TD></TR></TBODY></TABLE><FONT size=-1>
  <CENTER>Table 12 : Line Status Register </CENTER></FONT></CENTER>
  <P>The line status register is a read only register. Bit 7 is the error in 
  received FIFO bit. This bit is high when at least one break, parity or framing 
  error has occurred on a byte which is contained in the FIFO. </P>When bit 6 is 
  set, both the transmitter holding register and the shift register are empty. 
  The UART's holding register holds the next byte of data to be sent in parallel 
  fashion. The shift register is used to convert the byte to serial, so that it 
  can be transmitted over one line. When bit 5 is set, only the transmitter 
  holding register is empty. So what's the difference between the two? When bit 
  6, the transmitter holding and shift registers are empty, no serial 
  conversions are taking place so there should be no activity on the transmit 
  data line. When bit 5 is set, the transmitter holding register is empty, thus 
  another byte can be sent to the data port, but a serial conversion using the 
  shift register may be taking place. 
  <P></P>
  <P>The break interrupt (Bit 4) occurs when the received data line is held in a 
  logic state '0' (Space) for more than the time it takes to send a full word. 
  That includes the time for the start bit, data bits, parity bits and stop 
  bits. </P>
  <P>A framing error (Bit 3) occurs when the last bit is not a stop bit. This 
  may occur due to a timing error. You will most commonly encounter a framing 
  error when using a null modem linking two computers or a protocol analyzer 
  when the speed at which the data is being sent is different to that of what 
  you have the UART set to receive it at. </P>
  <P>A overrun error normally occurs when your program can't read from the port 
  fast enough. If you don't get an incoming byte out of the register fast 
  enough, and another byte just happens to be received, then the last byte will 
  be lost and a overrun error will result. </P>
  <P>Bit 0 shows data ready, which means that a byte has been received by the 
  UART and is at the receiver buffer ready to be read. </P>
  <P><A name=21></A><FONT size=+1>Modem Status Register (MSR)</FONT><BR>
  <HR>

  <P></P>
  <CENTER>
  <TABLE width="80%" border=1>
    <TBODY>
    <TR>
      <TD>
        <CENTER><B>Bit</B></CENTER></TD>
      <TD>
        <CENTER><B>Notes</B></CENTER></TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 7</CENTER></TD>
      <TD>Carrier Detect</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 6</CENTER></TD>
      <TD>Ring Indicator </TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 5</CENTER></TD>
      <TD>Data Set Ready</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 4</CENTER></TD>
      <TD>Clear To Send </TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 3</CENTER></TD>
      <TD>Delta Data Carrier Detect</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 2</CENTER></TD>
      <TD>Trailing Edge Ring Indicator</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 1</CENTER></TD>
      <TD>Delta Data Set Ready</TD></TR>
    <TR>
      <TD>
        <CENTER>Bit 0</CENTER></TD>
      <TD>Delta Clear to Send</TD></TR></TBODY></TABLE><FONT size=-1>
  <CENTER>Table 13 : Modem Status Register </CENTER></FONT></CENTER>
  <P>Bit 0 of the modem status register shows delta clear to send, delta meaning 
  a change in, thus delta clear to send means that there was a change in the 
  clear to send line, since the last read of this register. This is the same for 
  bits 1 and 3. Bit 1 shows a change in the Data Set Ready line where as Bit 3 
  shows a change in the Data Carrier Detect line. Bit 2 is the Trailing Edge 
  Ring Indicator which indicates that there was a transformation from low to 
  high state on the Ring Indicator line. </P>
  <P>Bits 4 to 7 show the current state of the data lines when read. Bit 7 shows 
  Carrier Detect, Bit 6 shows Ring Indicator, Bit 5 shows Data Set Ready &amp; 
  Bit 4 shows the status of the Clear To Send line. </P>
  <P><A name=22></A><FONT size=+1>Scratch Register</FONT><BR>
  <HR>

  <P></P>
  <P>The scratch register is not used for communications but rather used as a 
  place to leave a byte of data. The only real use it has is to determine 
  whether the UART is a 8250/8250B or a 8250A/16450 and even that is not very 
  practical today as the 8250/8250B was never designed for AT's and can't hack 
  the bus speed. </P></UL>
<HR>

<CENTER>
<TABLE width="90%" border=0>
  <TBODY>
  <TR>
    <TD width="20%" bgColor=black height=25><FONT face=ARIAL color=white 
      size=2><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/serial/serial.htm#TOC">Table of 
      Contents</A></CENTER></B></FONT></TD>
    <TD width="20%" bgColor=black height=25><FONT face=ARIAL color=white 
      size=2><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/serial/serial.htm#part1">Pt 1 
      Hardware</A></CENTER></B></FONT></TD>
    <TD width="20%" bgColor=black height=25><FONT face=ARIAL color=white 
      size=2><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/serial/serial.htm#part2">Pt 2 
      Registers</A></CENTER></B></FONT></TD>
    <TD width="20%" bgColor=black height=25><FONT face=ARIAL color=white 
      size=2><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/serial/serial1.htm#part3">Pt 3 
      Programming</A></CENTER></B></FONT></TD>
    <TD width="20%" bgColor=black height=25><FONT face=ARIAL color=white 
      size=2><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/serial/serial1.htm#part4">Pt 4 External 
      Hardware</A></CENTER></B></FONT></TD></TR></TBODY></TABLE></CENTER>
<HR>

<HR>

<CENTER>
<TABLE width="90%" border=0>
  <TBODY>
  <TR>
    <TD width="20%" bgColor=blue height=25><FONT face=ARIAL color=white><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/index.html#PARALLEL">Parallel 
      Ports</A></CENTER></B></FONT></TD>
    <TD width="20%" bgColor=blue height=25><FONT face=ARIAL color=white><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/index.html#SERIAL">Serial / RS-232 
      Ports</A></CENTER></B></FONT></TD>
    <TD width="20%" bgColor=blue height=25><FONT face=ARIAL color=white><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/index.html#INTERRUPTS">Interrupts</A></CENTER></B></FONT></TD>
    <TD width="20%" bgColor=blue height=25><FONT face=ARIAL color=white><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/index.html#ATKEYBOARDS">AT Keyboard 
      Ports</A></CENTER></B></FONT></TD>
    <TD width="20%" bgColor=blue height=25><FONT face=ARIAL color=white><B>
      <CENTER><A id=TITLEBLOCK 
      href="http://www.beyondlogic.org/index.html#USB">USB</A></CENTER></B></FONT></TD></TR></TBODY></TABLE>
<HR>
<FONT size=2>Copyright 1999-2000 <A 
href="mailto:cpeacock@senet.com.au(Craig%20Peacock)">Craig Peacock </A>- 
Saturday 11th November 2000. 
<HR>
</CENTER></FONT></FONT></BODY>
<!-- Mirrored from bos.asmhackers.net/docs/serial/docs/serial.htm by HTTrack Website Copier/3.x [XR&CO'2013], Tue, 07 Oct 2014 11:24:14 GMT -->
</HTML>
